package com.hingstd.lastwork.controllers;

import com.hingstd.lastwork.dao.UserAccountRepository;
import com.hingstd.lastwork.dao.WarnRepository;
import com.hingstd.lastwork.dto.UserAccountArticle;
import com.hingstd.lastwork.entities.UserAccount;
import com.hingstd.lastwork.entities.Warn;
import com.hingstd.lastwork.services.WarnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class HomepageController {

    @Autowired
    WarnService warnService;

    @Autowired
    UserAccountRepository userAccountRepository;

    @GetMapping("/")
    public String displayHomepage(Model model){
        List<Warn> warns = warnService.getAll();
        model.addAttribute("warns",warns);

        List<UserAccountArticle> userAccountArticles = userAccountRepository.userAccountArticles();
        model.addAttribute("userAccountArticles",userAccountArticles);
        return "home";
    }
}
